﻿using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;

namespace VNet.VisiSuite.Controls
{
    public class VNetUserControl : UserControl, INotifyPropertyChanged
    {
        private static FrameworkElement _element;

        protected VNetUserControl()
        {
            //DataContext = this;
        }

        public static void SetFrameworkElement(FrameworkElement element)
        {
            _element = element;
        }

        public static object FindResource(string resourceName)
        {
            return _element != null ? _element.FindResource(resourceName) : null;
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        // Raises this object's PropertyChanged event.
        protected void OnPropertyChanged(PropertyChangedEventArgs e)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, e);
            }
        }

        protected void NotifyPropertyChanged(string propertyName)
        {
            var e = new PropertyChangedEventArgs(propertyName);
            OnPropertyChanged(e);
        }

        #endregion
    }
}